
public class Player {

	private int playerNo;
	private String name;
	private int token;
	private int cash;
	private boolean out;
	
	private int xLocation;
	private int yLocation;
	private int currLoc = 0;
	private int nextLoc = 0;
	private int stop;
	
	private boolean outOfJailCard1;
	private boolean outOfJailCard2;
	private boolean jail;
	private int jailCounter;
	
	private Dice initialRoll;
	private int[][] lastThreeRolls = { {0, 0}, {0, 0}, {0, 0} };
	
	private Dice dice;
	private Properties property;
	
	public Player(String name, int token) {
		
		this.name = name;
		this.token = token;
		this.cash = 2500;
		this.currLoc = 0;
		this.out = false;
		
		this.outOfJailCard1 = false;
		this.outOfJailCard2 = false;
		this.jail = false;
		
		dice = new Dice();
		property = new Properties();
	}
	
	public boolean isOut() {
		
		return out;
	}

	public void setOut(boolean out) {

		this.out = out;
	}

	public int getJailCounter() {
		
		return jailCounter;
	}

	public void setJailCounter(int jailCounter) {
		
		this.jailCounter = jailCounter;
	}

	public Dice getInitialRoll() {
		
		return initialRoll;
	}

	public void setInitialRoll(Dice initialRoll) {
	
		this.initialRoll = initialRoll;
	}

	public boolean getOutOfJailCard1() {
		
		return outOfJailCard1;
	}

	public void setOutOfJailCard1(boolean outOfJailCard1) {
		
		this.outOfJailCard1 = outOfJailCard1;
	}
	
	public boolean getOutOfJailCard2() {
		
		return outOfJailCard2;
	}

	public void setOutOfJailCard2(boolean outOfJailCard2) {
		
		this.outOfJailCard2 = outOfJailCard2;
	}

	public boolean getJail() {
		
		return jail;
		
	}
	
	public void setJail(boolean jail) {
		
		this.jail = jail;
		
	}

	public Properties getProperties() {
		
		return property;
	}

	public void setProperties(Properties property) {
		
		this.property = property;
	}

	public Dice getDice() {
	
		return dice;
	}

	public void setDice(Dice dice) {
		
		this.dice = dice;
	}

	public int getPlayerNo() {
	
		return playerNo;
	}
	
	public String getName() {
		
		return name;
	}

	public int getToken() {
		
		return token;
	}
	
	public int getCash() {
		
		return cash;
	}
	
	public int getStop() {

		return stop;
	}

	public void setStop(int stop) {
		
		this.stop = stop;
	}
	
	public int[][] getLastThreeRolls() {
		
		return lastThreeRolls;
	}
	
	public int getXLocation() {
	
		return xLocation;
	}
	
	public int getYLocation() {
	
		return yLocation;
	}
	
	public int getCurrLoc() {
		
		return currLoc;
	}
	
	public int getNextLoc() {
		
		return nextLoc;
	}
	
	public void setPlayerNo(int playerNo) {
	
		this.playerNo = playerNo;
	}
	
	public void setName(String name) {
		
		this.name = name;
	}
	
	public void setToken(int token) {
		
		this.token = token;
	}
	
	public void setCash(int cash) {
		
		this.cash = cash;
	}
	
	public void setLastThreeRolls(int lastThreeRolls1, int lastThreeRolls2) {
		
		this.lastThreeRolls[0][0] = this.lastThreeRolls[1][0];
		this.lastThreeRolls[0][1] = this.lastThreeRolls[1][1];
		this.lastThreeRolls[1][0] = this.lastThreeRolls[2][0];
		this.lastThreeRolls[1][1] = this.lastThreeRolls[2][1];
		this.lastThreeRolls[2][0] = lastThreeRolls1;
		this.lastThreeRolls[2][1] = lastThreeRolls2;
	}
	
	public void resetLastThreeRolls() {
		
		for (int x = 0; x < 3; x++) {
			
			for (int y = 0; y < 2; y++) {
				
				this.lastThreeRolls[x][y] = 0;
			}
		}
	}
	
	public Dice initialRollDice() {
		
		dice.rollDice();
		this.setInitialRoll(dice);
		
		return dice;
	}
	
	public Dice rollDice() {
		
		Object[] options = { "Okay" };
		
		dice.rollDice();
		this.setLastThreeRolls(dice.getDice1(), dice.getDice2());
		
		if (this.getJail() == false) {
						
			if (Jail.threeDoubles(this) == false) {
				
				this.setNextLoc();
				
				//System.out.println(this.lastThreeRolls[0][0] + ", " + this.lastThreeRolls[0][1] + ", " + this.lastThreeRolls[1][0] + ", " + this.lastThreeRolls[1][1] + ", " + this.lastThreeRolls[2][0] + ", " + this.lastThreeRolls[2][1]);
			}
			
			else {
				
				BoardGUI.dynamicDialogBox(options, "images/Misc/Go to Jail Dice.png", "Go to Jail");
				
				if (this.getCurrLoc() > 10) {
					
					this.setStop(50);
				}
				
				else {
					
					this.setStop(10);
				}
				
				this.presetNextLoc(10);			
				this.setJail(true);
				this.setJailCounter(4);
				Location.setRelocate(true);
				Board.setIgnoreGo(true);
			}
		}
		
		else {
			
			if (dice.getDice1() == dice.getDice2()) {
				
				BoardGUI.dynamicDialogBox(options, "images/Misc/Rolled Double.png", "Go to Jail");
				
				this.setJail(false);
				this.resetLastThreeRolls();
				this.setNextLoc();
			}
		}
		
		return dice;
	}
	
	public void setXLocation(int xLocation) {
	
		this.xLocation = xLocation;
	}
	
	public void setYLocation(int yLocation) {
	
		this.yLocation = yLocation;
	}
	
	public void setCurrLoc(int currLoc) {
		
		this.currLoc = currLoc;
	}
	
	public void setNextLoc() {
		
		nextLoc += dice.getSum();
		
		if (nextLoc > 39) {
			
			nextLoc -= 40;
		}
	}
	
	public void presetNextLoc(int nextLoc) {
		
		this.nextLoc = nextLoc;
	}
}